package com.example.footballsystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.footballsystem.entity.User;
import org.apache.ibatis.annotations.*;

import java.sql.Timestamp;
import java.util.List;

@Mapper
public interface UserAccountMapper extends BaseMapper<User> {
    //查询所有用户
    @Select("select * from user")
    public List<User> getAllUser();
    //获取账户
    @Select("select * from user where Account=#{account}")
    public User getUserByAccount(String account);
    @Select("select * from user where Phone=#{phone}")
    public User getUserByPhone(String phone);
    @Select("select * from user where Email=#{email}")
    public User getUserByEmail(String email);
    @Select("select * from user where UserName=#{userName}")
    public User getUserByUserName(String userName);
    //更改用户
    @Update("update user set Password=#{password},username=#{username},Phone=#{phone},Email=#{email} where Account=#{account}")
    public Boolean updateUser(User user);
    @Update("update user set url=#{url} where Account=#{account}")
    public Boolean updateUserUrl(String url, String account);
    @Update("update user set username=#{username} where Account=#{account}")
    public Boolean updateUserName(String account,String username);
    @Update("update user set Password=#{password} where Account=#{account}")
    public Boolean updateUserPassword(String account,String password);
    @Update("update user set Email=#{email} where Account=#{account}")
    public Boolean updateUserEmail(String account,String email);
    @Update("update user set sex=#{sex} where Account=#{account}")
    public Boolean updateUserSex(String account,String sex);
    @Update("update user set birthday=#{birthday} where Account=#{account}")
    public Boolean updateUserBirthday(String account,String birthday);
    //添加账户
    @Insert("insert into user(account, password, username, url,phone, email,sex,birthday,createDate) values(#{account},#{password},#{username},#{url},#{phone},#{email},#{sex},#{birthday},#{createDate})")
    public Integer addUser(User user);
    //删除用户
    @Delete("delete from user where Account=#{account}")
    public Boolean deleteUser(String account);
    //获取密码
    @Select("select password from user where account=#{account}")
    public String getPassword(String account);
    @Update("update user set createDate=#{timestamp} where Account=#{account}")
    public Boolean setCreateTime(Timestamp timestamp,String account);
    @Update("update user set score=score+#{score} where Account=#{account}")
    public Boolean setScore(String account,int score);
    @Select("select count(login_time) from user_dairy group by User_Account")
    public List<Integer> countLoginTime();


}

